<?php
/**
 * Definition for a binary tree node.
 * class TreeNode {
 *     public $val = null;
 *     public $left = null;
 *     public $right = null;
 *     function __construct($val = 0, $left = null, $right = null) {
 *         $this->val = $val;
 *         $this->left = $left;
 *         $this->right = $right;
 *     }
 * }
 */

class Solution {
    public function isInBST($root, $target)
    {
        if ($root == null) {
            return false;
        }
        if ($root->val == $target) {
            return true;
        }
        return $root->val > $target ? $this->isInBST($root->left, $target) : $this->isInBST($root->right, $target);
    }
}